package hw;

import sk.Util;

import javax.swing.*;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

public class ATM extends JFrame {
    private LoginPanel loginPanel = new LoginPanel(this);
    private MenuPanel menuPanel = new MenuPanel(this);
    private SavePanel savePanel = new SavePanel(this);
    private GetPanel getPanel = new GetPanel(this);
    private LookPanel lookPanel = new LookPanel(this);
    private Image bgImg = Util.getImage("/images/background.jpg");
    private CardLayout cardLayout = new CardLayout();

    public ATM() {
        this.setContentPane(new JPanel() {
            @Override
            protected void paintComponent(Graphics g) {
                super.paintComponent(g);
                g.drawImage(bgImg, 0, 0, 1024, 768, this);
            }
        });

        this.setSize(1024, 768);
        this.setLocationRelativeTo(this);
        this.setLayout(cardLayout);
        this.setTitle("ATM");
        this.setDefaultCloseOperation(EXIT_ON_CLOSE);

        this.add("login", loginPanel);
        this.add("menu", menuPanel);
        this.add("save", savePanel);
        this.add("get", getPanel);
        this.add("look", lookPanel);


        this.setVisible(true);

    }

    public void switchPanel(String name) {
        cardLayout.show(this.getContentPane(), name);
    }


    public static void main(String[] args) {
        new ATM();
    }


}
